package com.cskaoyan.service.statisticalservice;

import com.cskaoyan.bean.statisticalbean.StatisticalBean;
import com.cskaoyan.mapper.statisticalmapper.StatisticalMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.*;

/**
 * @author ked
 * @createTime 2021年05月10日 20:15:00
 */

@Service
public class StatisticalServiceImpl implements StatisticalService{

    @Resource
    StatisticalMapper statisticalMapper;

    @Override
    public StatisticalBean queryUserStatistical() {
        List<String> columns = new ArrayList<>();
        columns.add("day");
        columns.add("users");
        List<Map> rows = statisticalMapper.selectUserStatistical();
        StatisticalBean statisticalBean = new StatisticalBean();
        statisticalBean.setColumns(columns);
        statisticalBean.setRows(rows);
        return statisticalBean;

    }

    @Override
    public StatisticalBean queryOrderStatistical() {
        List<String> columns = new ArrayList<>();
        columns.add("day");
        columns.add("orders");
        columns.add("customers");
        columns.add("amount");
        columns.add("pcr");
        List<Map> rows = statisticalMapper.selectOrderStatistical();
        StatisticalBean statisticalBean = new StatisticalBean();
        statisticalBean.setColumns(columns);
        statisticalBean.setRows(rows);
        return statisticalBean;

    }

    @Override
    public StatisticalBean queryGoodsStatistical() {
        List<String> columns = new ArrayList<>();
        columns.add("day");
        columns.add("orders");
        columns.add("products");
        columns.add("amount");
        List<Map> rows = statisticalMapper.selectGoodsStatistical();
        StatisticalBean statisticalBean = new StatisticalBean();
        statisticalBean.setColumns(columns);
        statisticalBean.setRows(rows);
        return statisticalBean;
    }
}
